// pages/homepage/homepage.js
Page({
  data: {
    searchValue: '', // 绑定输入框的值
    iconList: [{
        iconType: "success"
      }, {
        iconType: "success_no_circle"
      }, {
        iconType: "info"
      }, {
        iconType: "warn"
      },
      {
        iconType: "waiting"
      }, {
        iconType: "cancel"
      }, {
        iconType: "download"
      }, {
        iconType: "search"
      },
      {
        iconType: "clear"
      }
    ],

    commodityList: [{
        id: 1,
        img: '../../image/commodity/img1.jpg',
        userImg: '../../image/user/user2.jpg',
        username: '小熊软糖',
        price: '3'
      },
      {
        id: 2,
        img: '../../image/commodity/img2.jpg',
        userImg: '../../image/user/user1.jpg',
        username: '芒果干',
        price: '5'
      },
      {
        id: 3,
        img: '../../image/commodity/img3.jpg',
        userImg: '../../image/user/user1.jpg',
        username: '薯片',
        price: '2'
      },
      {
        id: 4,
        img: '../../image/commodity/img4.jpg',
        userImg: '../../image/user/user1.jpg',
        username: '巧克力',
        price: '4'
      }
    ]
  },

  onInput: function (e) {
    this.setData({
      searchValue: e.detail.value
    });
  },
  onSearch: function () {
    console.log("搜索内容：", this.data.searchValue);
    // 这里可以进行搜索操作，例如发送请求到服务器获取数据
  },

  switchTab: function (e) {
    const url = e.currentTarget.dataset.url;
    wx.navigateTo({
      url: url
    });
  },

  onLoad(options) {
    var that = this
    wx.request({
      url: 'http://127.0.0.1:3000/',
      success: function (res) {
        console.log(res.data)
        // that.setData({ names: res.data })
      }
    })
  },
})